<!-- Aside 侧边栏 -->
<template>
  <div style="height:100vh;overflow: auto;">
    <el-menu :default-openeds="[]" style="height: 100%;" background-color="#fff" text-color="gray" active-text-color="#19CAAD" :collapse-transition="false"
      :collapse="isCollapse" router>
      <!-- @select="handleSelect" -->
      <div style="margin:0 auto;text-align:center;margin-top:10px">
        <img src="../assets/zhixue.jpg" alt="" style="width: 80%; ">
        <b style="color: white;" v-show="logitextshow">智学it课堂</b>
      </div>

      <div v-for="item in menus" :key="item.id">
        <div v-if="item.path">
          <el-menu-item :index="item.path">
            <i :class="item.icon"></i>
            <span slot="title">{{ item.mname }}</span>
          </el-menu-item>
        </div>
        <div v-else>
          <el-submenu :index="item.id + ''">
            <template slot="title">
              <i :class="item.icon"></i>
              <span slot="title">{{ item.mname }}</span>
            </template>
            <div v-for="subItem in item.children" :key="subItem.id">
              <el-menu-item :index="subItem.path">
                <i :class="subItem.icon"></i>
                <span slot="title">{{ subItem.mname }}</span>
              </el-menu-item>
            </div>
          </el-submenu>
        </div>
      </div>
    </el-menu>
  </div>
</template>

<script>
export default {
  name: "Aside",
  props: {
    isCollapse: Boolean,
    logitextshow: Boolean,
  },
  data() {
    return {
      menus: localStorage.getItem("menus") ? JSON.parse(localStorage.getItem("menus")) : [],
      //侧边栏默认展开
      // opens: localStorage.getItem("menus") ? JSON.parse(localStorage.getItem("menus")).map(v => v.id + '') : []
    };
  },
  created() {
    //获取菜单数据 （已作废）
    // this.getMenusList()
  },
  methods: {
    // 菜单查询方法 （已作废）
    // handleSelect(index) {
    // },
    // getMenusList() {
    //   let roleMenus = localStorage.getItem("roleMenus") ? JSON.parse(localStorage.getItem("roleMenus")) : []
    //   if (roleMenus) {
    //     // 从后台获取菜单数据
    //     this.request.get("/User/MenuList").then(res => {
    //       // 重新赋值后台的菜单数据
    //       this.roleMenus = res.data
    //     })
    //   }
    // }
  },
};
</script>

 <style>
.el-menu-item.is-active {
  background-color: rgb(220, 247, 220) !important;
}
.el-menu-item:hover {
  background-color: rgb(224, 245, 227) !important;
}

.el-submenu__title:hover {
  background-color: rgb(229, 245, 227) !important;
}
/*解决收缩菜单文字不消失问题*/
.el-menu--collapse span {
  visibility: hidden;
}
</style>
